package com.fqgj.sentry.policy.client;

import com.fqgj.sentry.policy.entity.PcExecutorEntity;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: yujianfu (mr.vencnet@gmail.com)
 * Date: 2017/7/18
 * Time: 下午12:17
 * <p>
 * 执行者服务
 */
public interface PolicyExecutorService {

    /**
     * @param pcExecutorEntity
     * @return
     */
    Long insertPolicyExecutor(PcExecutorEntity pcExecutorEntity);

    /**
     * 拷贝某个执行者时要将该拷贝的执行者对应的策略和规则都拷贝一份
     *
     * @param copyExecutorId
     * @param newExecutorId
     * @return
     */
    Boolean copyPolicyExecutor(Long copyExecutorId, Long newExecutorId);

    /**
     * 根据执行者id 删除该执行者
     *
     * @param executorId
     * @return
     */
    Boolean deletePolicyExecutor(Long executorId);

    /**
     * 修改 待发布版本的描述信息
     *
     * @param executorId
     * @param info
     * @return
     */
    Boolean updatePolicyExecutorInfo(Long executorId, String info);

    /**
     * 丢弃  待发布版本
     *
     * @param executorId
     * @return
     */
    Boolean dropPolicyExecutor(Long executorId);

    /**
     * 设置当前执行者开关
     *
     * @param executorId
     * @param open(0)
     * @return
     */
    Boolean setExecutorSwitch(Long executorId, Integer open);

    /**
     * 设置挑战者线上版本的占比
     *
     * @param executorId
     * @param percent
     * @return
     */
    Boolean setChallengerExecutorPercent(Long executorId, Integer percent);

    /**
     * 回滚 历史版本
     *
     * @param executorId
     * @return
     */
    Boolean rollBackExecutor(Long executorId);

    /**
     * 发布待发布版本
     *
     * @param executorId
     * @return
     */
    Boolean releaseExecutor(Long executorId);

    /**
     * 根据策略集id查询当前策略集下面某个执行者的当前版本
     *
     * @param policySetsId
     * @return
     */
    PcExecutorEntity selectPcExecutorCurrent(Long policySetsId, Integer executorType, Integer active);

    /**
     * 根据策略集id 查询当前策略集下面的某个执行者的历史版本
     *
     * @param policySetsId
     * @param type
     * @return
     */
    List<PcExecutorEntity> selectPcExecutorHistoryList(Long policySetsId, Integer type);

    /**
     * 根据策略集id 查询当前策略集下面的某个执行者的待发布版本
     *
     * @param policySetsId
     * @param type
     * @return
     */
    PcExecutorEntity selectPcExecutorPending(Long policySetsId, Integer type);

    /**
     * 根据策略集id获取该策略集下的所有线上执行者
     *
     * @param policySetsId
     * @return
     */
    List<PcExecutorEntity> selectPcCurrentAllExecutor(Long policySetsId);

    /**
     * 根据 executorId 查询执行者
     *
     * @param executorId
     * @return
     */
    PcExecutorEntity selectByExecutorId(Long executorId);

}
